{%extends '../base/base.tpl'%}

{%block 'title'%}运营管理-商品管理{%/block%}

{%block 'header_css'%}
<link href="../../static/js/common/plugins/chosen/chosen.css?__inline" rel="stylesheet">
<link href="../../static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<link href="../../static/css/plugins/cropper/cropper.min.css" rel="stylesheet">  <!--图片上传加裁剪-->


<!-- 上传组件 -->
<link href="../../static/js/common/plugins/fileinput/fileinput.min.css" rel="stylesheet"/>
<!--富文本 -->
<link href="../../static/js/common/plugins/kindeditor/themes/qq/qq.css" rel="stylesheet"/>
<link href="../../static/css/animate.min.css" rel="stylesheet">
<link href="../../static/css/style.min.css?__inline" rel="stylesheet">
<link href="../../static/css/common.css?__inline" rel="stylesheet">


<style type="text/css">
table{font-size:13px;text-align:center;}
thead{font-weight:bold;text-align:center;}
th{text-align: center;}
.list_edit_table{}
.is_must{line-height: 34px;}
table a{display: inline-block;}
.img-preview-sm{height:78px;}
.note-editor .note-editable{background: #fff}
.note-editable{min-height: 200px;}
.tangram-suggestion-main{z-index: 10000}
.BMapLabel{margin-top: -20px;max-width: inherit;}
.btn-danger{background-color: #ec4758;border-color: #ec4758;color: #FFF;}
.btn-success{background-color: #1a7bb9;border-color: #1a7bb9;color: #FFF;}
</style>
{%/block%}

{%block 'header_js'%} 

{%/block%}

{%block 'foot'%}

{%/block%}

{%block 'body'%}
{%assign var=table_operation value="true" %}
{%assign var=table_btn value=array(
    [
        'url'=>'#',
        'text'=>'编辑',
        'type'=>'edit_btn',
        'data_target'=>'#table_detail',
        'data_toggle'=>'modal'
    ],
    [
        'url'=>'#',
        'text'=>'详情',
        'type'=>'detail_btn',
        'data_target'=>'#table_detail',
        'data_toggle'=>'modal'
    ],
    [
        'url'=>'#',
        'text'=>'删除',
        'type'=>'del_btn',
        'data_target'=>'null',
        'data_toggle'=>'null'
    ]
) %}
<div id="wrapper">
    {%include file="../../widget/left_menu.tpl"%}
    <div id="page-wrapper" class="gray-bg dashbard-1">
    {%include file="../../widget/header.tpl"%}
    <div class="row J_mainContent" id="content-main">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h3>商品管理</h3>
            </div>
            <div class="ibox-content">
                <div class="row">
                    <form method="get" class="form-horizontal">
                        <div class="form-group">
                            <div class="col-sm-4">
                                <label class="col-sm-3 control-label">商家名称:</label>
                                <div class="col-md-9">
                                    <select class="form-control chosen-select" name="vender_id" id="goods_vender_id">
                                    </select>
                                </div>
                            </div>
                            <div class="col-sm-4">
                                <label class="col-sm-3 control-label">商品名称:</label>
                                <div class="col-md-9">
                                    <input type="text" placeholder="商家名称" name="goods_name" id="goods_goods_name" class="form-control">
                                </div>
                            </div>
                            <div class="col-sm-4">
                                <div class="radio i-checks col-md-4">
                                    <label class="">
                                        <div class="iradio_square-green"><input type="radio" value="1" id='goods_goods_type_ticket' class="order_radioed" name="goods_type_show"></div> <i></i> 票类商品</label>
                                </div>
                                <div class="radio i-checks col-md-4">
                                    <label class="">
                                        <div class="iradio_square-green"><input type="radio" value="0" id='goods_goods_type_entity' class="order_radioed"  name="goods_type_show"></div> <i></i> 实体商品</label>
                                </div>
                                <div class="radio i-checks col-md-4">
                                    <label class="">
                                        <div class="iradio_square-green"><input type="radio" value="0" id='goods_goods_type_sharecard' class="order_radioed"  name="goods_type_show"></div> <i></i> 乐享卡</label>
                                </div>
                                <input type="hidden" value="0" id='hid_goods_type'  name="goods_type">
                                <input type="hidden" value="0" id='hid_is_sharecard'  name="is_share_card">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 pull-right">
                                <label class="col-sm-3 control-label"></label>
                                <div class="col-md-9" id="regionWrap">
                                    <button class="btn btn-primary pull-right"  type="submit"><i class="fa fa-search"></i>&nbsp;搜索</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="hr-line-dashed"></div>
                <a type="button" href="#" class="btn btn-primary new_file_coupon" data-toggle="modal" data-target="#table_detail">新建商品</a>
                {%include file="../../widget/table_mod.tpl"%}
                {%include file="../../widget/pagination.tpl"%}

            </div>
        </div>
    </div>
    {%include file="../../widget/footer.tpl"%}
    </div>
</div>
    {%include file="../../widget/editable_mod.tpl"%}
{%/block%}
  
{%block 'foot_js'%}
<script src="../../static/js/common/plugins/chosen/chosen.jquery.js?__inline"></script>
<script src="../../static/js/common/content.min.js"></script>
<script src="../../static/js/common/plugins/validate/jquery.validate.min.js"></script>
<script src="../../static/js/common/plugins/validate/messages_zh.min.js"></script>
<script src="../../static/js/common/jquery.form.js"></script>
<script src="../../static/js/common/plugins/layer/laydate/laydate.js"></script> 
<script src="../../static/js/common/plugins/sweetalert/sweetalert.min.js"></script>
<script src="../../static/js/common/plugins/jeditable/jquery.jeditable.js"></script> 
<script src="../../static/js/common/plugins/dataTables/jquery.dataTables.js"></script> 
<script src="../../static/js/common/plugins/dataTables/dataTables.bootstrap.js"></script> 
<script src="../../static/js/common/plugins/iCheck/icheck.min.js"></script> 
<script src="../../static/js/common/plugins/cropper/cropper.min.js"></script> 
<script src="../../static/js/common/plugins/ajaxfileupload/ajaxfileupload.js"></script> 

<!-- 上传组件 -->
<script src="../../static/js/common/plugins/fileinput/fileinput.min.js"></script>
<script src="../../static/js/common/plugins/fileinput/fileinput_locale_zh.js"></script>
<!-- 富文本 -->
<script type="text/javascript" charset="utf-8" src="../../static/js/common/plugins/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../../static/js/common/plugins/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="../../static/js/common/plugins/ueditor/lang/zh-cn/zh-cn.js"></script>
<!-- <script src="../../static/js/table/tableoperation.js"></script> -->
<script src="../../static/js/table/tableModel.js"></script>
<script type="text/javascript">
var WinUrl = window.location.search;
$(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});
 


var customFun = {
    
    
  
};
common_option = customFun;
function getUrlParam(name){   //获取URL参数值
    //构造一个含有目标参数的正则表达式对象  
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");  
    //匹配目标参数  
    var r = decodeURI(window.location.search.substr(1)).match(reg);  
    //返回参数值  
    if (r!=null) return unescape(r[2]);  
    return null;  
}
$(function(){
    venderAjax();
    is_share_goods();
    if(WinUrl.indexOf("goods_name") > 0){
        $("#goods_goods_name").val(getUrlParam('goods_name'))
    }

    if(WinUrl.indexOf("goods_type") > 0){
        if(getUrlParam('goods_type') == "0"){
            $("#goods_goods_type_ticket").attr("checked","checked");
            $(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})
        }else if(getUrlParam('goods_type') == "1"){
            $("#goods_goods_type_entity").attr("checked","checked");
            $(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})
        }
        
    }
    if(WinUrl.indexOf("is_share_card") > 0 && getUrlParam('is_share_card') == "1"){
        $("#goods_goods_type_sharecard").attr("checked","checked");
        $(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})
    }
    $("#goods_goods_type").change(function(){
        // is_share_goods();
    })
    $('.order_radioed').on('ifChecked', function(event){ //ifCreated 事件应该在插件初始化之前绑定 
        var hid = $(this).attr('id')  ;
        if(hid == "goods_goods_type_ticket"){
            $("#hid_goods_type").val('0');
            $("#hid_is_sharecard").val(null);
        }else if(hid=="goods_goods_type_entity"){
            $("#hid_goods_type").val('1');
            $("#hid_is_sharecard").val(null);
        }else if(hid=="goods_goods_type_sharecard"){
            $("#hid_goods_type").val(null);
            $("#hid_is_sharecard").val("1");
        }
    }); 

    function is_share_goods(){
        if($("#goods_goods_type").val() == 1){
            $("#goods_is_share_card").val("0").attr("disabled","disabled");
        }else{
            $("#goods_is_share_card").removeAttr("disabled");
        }
    }
    function venderAjax(){
        $.ajax({
            url:"/ajax/call/basedata/vender_list",
            type:'post',
            success:function(res){
                if(res.data_list!=undefined){
                    var dlist = res.data_list;
                    var html = '<option value="">未选择</option>';
                    for(var i = 0;i < dlist.length; i++ ){
                        if(WinUrl.indexOf("vender_id") > 0 && getUrlParam('vender_id') != null && getUrlParam('vender_id') != ""){
                            if(getUrlParam('vender_id') == dlist[i].id ){
                                html +='<option value="'+dlist[i].id+'" selected>'+dlist[i].name+'</option>'
                            }else{
                                html +='<option value="'+dlist[i].id+'" >'+dlist[i].name+'</option>'
                            }
                        }else{
                            html +='<option value="'+dlist[i].id+'" >'+dlist[i].name+'</option>'
                        }
                    }
                    $("#goods_vender_id").html("").append(html);
                    $('#goods_vender_id').chosen({});
                }

            }  

        });
    }
});
  

  
  
  

 

</script> 
{%/block%}

